package com.un10.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.un10.entity.PropicInfo;
import com.un10.service.PropicinfoService;
import com.un10.util.Result;

@Controller
public class PropicinfoContorller {

	@Autowired
	PropicinfoService PropicinfoService;

	@RequestMapping("/houtai/getPropicinfo")
	@ResponseBody
	public Object getPropicinfo(@RequestParam("page") int page, @RequestParam("limit") int limit,
			@RequestParam("proID") Integer proID) {
		
		List<PropicInfo> prosclass = PropicinfoService.findAllPropicinfo((page - 1) * limit, limit, proID);

		if (proID == null ) {
			proID = null;
		}
		int count = PropicinfoService.getCount();
		System.out.println(proID);
		com.un10.util.Result res = new com.un10.util.Result(0, "", count, prosclass);
		return res;
	}

	@RequestMapping("/houtai/propicinfoadd")
	@ResponseBody
	public Object propicinfoadd(@RequestParam Map<String, Object> map) {

		System.out.println(map.get("className"));
		int i = PropicinfoService.findPropicinfoAdd(map);
		Result res = new Result(0, "", i, true);
		return res;
	}
	
	@RequestMapping("/houtai/updatePropicinfo")
	@ResponseBody
	public Object updatePropicinfo(@RequestParam Map<String, Object> map) {
	
		int i = PropicinfoService.findPropicinfoUpdate(map);
		Result res = new Result(0, "", i, true);
		return res;
	}
  
	

	@RequestMapping("/houtai/deletePropicinfo")
	@ResponseBody
	public Object deletePropicinfo(@RequestParam("picID") Integer picID) {
		int i = PropicinfoService.findPropicinfoDelete(picID);
		Result res = new Result(0, "", i, true);
		return res;
	}
}
